package com.ffms.servlet;

import com.ffms.dao.impl.MoneyDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/DeleteMoneyServlet")
public class DeleteMoneyServlet extends HttpServlet {


    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        this.doPost(request, response);
    }


    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        //获取要删除的成员姓名
        String id = request.getParameter("id");
        String flag = request.getParameter("flag");
        //完成删除操作
        MoneyDaoImpl moneyDaoImpl = new MoneyDaoImpl();
        try {
            moneyDaoImpl.deleteMoneyById(id);
            request.getRequestDispatcher("/AllMoneyServlet?flag=" + flag).forward(request, response);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}
